import React, { Component } from 'react'
import { Timeline } from 'antd';
import u from '../../../common.js'
import $ from 'jquery'
import '../../../static/routineMonitoring/gongzhong.less'
import '../../../static/routineMonitoring/gzDetail.less'

class GzDetail extends Component{
  constructor(props) {
    super(props)
    this.state = {
      names: [u.getStore('gzName')],
            flag: true,
            index: 0,
            search: [{ src: "../../static/image/tou_fifty.png", title: '宋中继' }, { src: "../../static/image/tou_fifty.png", title: '王小筱' }, { src: "../../static/image/tou_fifty.png", title: '鲁达' }, { src: "../../static/image/tou_fifty.png", title: '宋中继' }, { src: "../../static/image/tou_fifty.png", title: '钱度' }, { src: "../../static/image/tou_fifty.png", title: '李四' },],
            base: [],
            block: 0,
            mynumber: 11,
            downLoad: true,
            data: {},
            str1: '',
            str2: '',
            img: [],
            top: '-8px',
    }
  }
  componentDidMount(){
    let that = this;
    console.log(localStorage.getItem('searchKey'))
    u.dataStatistics({ 
      id: this.props.location.search.split('?')[1] ,
      keyWord:localStorage.getItem('searchKey'),
    }, data => {
      if (data.data.length == 0) return
      console.log(data)
      let str = data.data[0].content;
      str = str.replace(/<br \/>/g, '').replace(/<vrv-img\/>/g, '')
      let img = data.data[0].img
      let str1 = str.substr(0, str.length / 2 - 1)
      let str2 = str.substr(str.length / 2)
      let arr = img.split('http');
      arr.shift();
      let i = 0;
      for (i; i <= arr.length - 1; i++) {
          arr[i] = 'http' + arr[i]
      }

      that.setState((prevState, props) => ({
          data: data.data[0],
          str1: str1,
          str2: str2,
          img: arr
      }))
     })

  }


  render() {
    return (
      <div className="wechat">
         {/* <div className='nav_bc nav_bc_two_active' style={{ paddingTop: '20px' }} >
             <h3>韩国全面部署2萨德 出动员封锁出动8000名警员封锁道路</h3>
             <div className='nav_bc_title'><span><b>发布人：</b>艾久萧</span><span><b>发布时间：</b>2017-03-07 14:41:05</span><span><b>转载自：</b>新浪新闻-把酒社区</span></div>
             <p>155885222222222</p>
             <div className='nav_bc_img' style={{ height: 'auto', padding: this.state.img.length !== 0 ? '30px 60px 0px 60px' : '0' }}>{this.state.img && this.state.img.map((item, index) => {
                 return (<img key={index} src={item} alt="" />)
             })}</div>
             <p>{this.state.str2}</p>
          </div> */}
          <div className='nav_bc nav_bc_two_active' style={{ paddingTop: '20px' }} >
                    <h3 dangerouslySetInnerHTML={{ __html: this.state.data.title }}></h3>
                    <div className='nav_bc_title'><span><b>发布人：</b>{this.state.data.author || '艾久萧'}</span><span><b>发布时间：</b>{u.unixTime(this.state.data.addTime) || '2017-03-07 14:41:05'}</span><span><b>转载自：</b>{this.state.data.webSite || '新浪新闻-把酒社区'}</span></div>
                    <p dangerouslySetInnerHTML={{ __html: this.state.str1 }}></p>
                    <div className='nav_bc_img' style={{ height: 'auto', padding: this.state.img.length !== 0 ? '30px 60px 0px 60px' : '0' }}>{this.state.img && this.state.img.map((item, index) => {
                        return (<img key={index} src={item} alt="" />)
                    })}</div>
                    <p dangerouslySetInnerHTML={{ __html: this.state.str2 }}></p>
        </div>
      </div>

    
    )
    
  }
  
}

export default GzDetail